package Acwing;

import java.util.Scanner;

public class No4 {
    public static void main(String[] args) {
        Scanner sc  = new Scanner(System.in);
        int n = sc.nextInt();
        int V = sc.nextInt();
        int[] vs = new int[n+1];
        int[] ws = new int[n+1];
        int[] ns = new int[n+1];
        for(int i = 1; i<=n; i++){
            vs[i] = sc.nextInt();
            ws[i] = sc.nextInt();
            ns[i] = sc.nextInt();
        }
        long[][] dp = new long[n+1][V+1];
        for(int i = 1; i<=n; i++){
            for(int j = 0; j<=V; j++){
                long tmp = 0;
                for(int l = 0;l<=ns[i]; l++){
                    if(j< l*vs[i]) break;
                    tmp = Math.max(tmp,l*ws[i] + dp[i -1][j - l*vs[i]]);
                }
                dp[i][j] = tmp;
            }
        }
        System.out.println(dp[n][V]);
    }
    // public static long process(int index, int rest, int[] vs,int[] ws,int[] ns){
    //     if(index == 0) return 0;
    //     long tmp  = 0;
    //     for(int i = 0; i<= ns[index]; i++){
    //         if(rest < i*vs[index]){
    //             break;
    //         }
    //         tmp = Math.max(tmp,i*ws[index] + process(index - 1, rest - i*vs[index], vs, ws, ns));
    //     }
    //     return tmp;
    // }
}
